home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / gamesmaster / source / asm / screendemos / scrollmemory.s < prev    next >
Encoding:
Text File  |  1996-09-11  |  3.7 KB  |  133 lines

  1. ;Scroll Memory
  2. ;-------------
  3. ;This demo shows you the power of the scrolling features by allowing you
  4. ;to scroll all over your chip ram :-).  Usually you would set limits to stop
  5. ;you from going over the boundaries, but that's up to you.
  6. ;
  7. ;Use mouse to move around, LMB exits.
  8.  
  9.     opt    o+
  10.  
  11.     INCLUDE    "exec/exec_lib.i"
  12.     INCLUDE    "games/games_lib.i"
  13.     INCLUDE    "games/games.i
  14.  
  15. CALL    MACRO
  16.     jsr    _LVO\1(a6)
  17.     ENDM
  18.  
  19.     SECTION    "ScrollMemory",CODE
  20.  
  21. ;===========================================================================;
  22. ;                             INITIALISE DEMO
  23. ;===========================================================================;
  24.  
  25. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  26.     move.l    ($4).w,a6
  27.     lea    GMS_Name(pc),a1
  28.     moveq    #$00,d0
  29.     CALL    OpenLibrary
  30.     move.l    d0,GMS_Base
  31.     beq.s    Quit
  32.  
  33.     move.l    GMS_Base(pc),a6
  34.     CALL    SetUserPri
  35.  
  36.     move.l    GMS_Base(pc),a6      ;Tell GMS that we want to add a
  37.     lea    ScreenStruct(pc),a0  ;screen for use.
  38.     CALL    Add_Screen
  39.     tst.l    d0
  40.     bne.s    Error
  41.  
  42.     lea    Picture(pc),a1           ;a1 = Picture struct.
  43.     move.l    SS_MemPtr1(a0),PIC_Data(a1)
  44.     lea    PicFile(pc),a0           ;a0 = Picture file.
  45.     CALL    LoadPic
  46.     tst.w    d0
  47.     bne.s    ReturnToDOS
  48.  
  49.     lea    ScreenStruct(pc),a0  ;Now show the screen/pic.
  50.     CALL    Show_Screen
  51.  
  52.     moveq    #JPORT1,d0           ;Initialise the mouse port.
  53.     CALL    Read_Mouse
  54.  
  55. ;===========================================================================;
  56. ;                                MAIN LOOP
  57. ;===========================================================================;
  58.  
  59. Loop:    moveq    #JPORT1,d0
  60.     CALL    Read_Mouse
  61.     btst    #MB_LMB,d0
  62.     bne.s    ReturnToDOS
  63.     move.w    d0,d1
  64.     asr.w    #8,d0                ;d0 = X Change
  65.     add.w    d0,SS_PicXOffset(a0)
  66.     ext.w    d1
  67.     add.w    d1,SS_PicYOffset(a0)
  68.     CALL    Move_Picture
  69.     CALL    Wait_OSVBL
  70.     bra.s    Loop
  71.  
  72. ;===========================================================================;
  73. ;                              RETURN TO DOS
  74. ;===========================================================================;
  75.  
  76. ReturnToDOS:
  77.     move.l    GMS_Base(pc),a6
  78.     lea    ScreenStruct(pc),a0
  79.     CALL    Delete_Screen        ;Give back screen memory etc.
  80. Error:    move.l    GMS_Base(pc),a1
  81.     move.l    ($4).w,a6
  82.     CALL    CloseLibrary
  83. Quit:    MOVEM.L    (SP)+,A0-A6/D1-D7
  84.     moveq    #$00,d0
  85.     rts
  86.  
  87. ;===========================================================================;
  88. ;                                  DATA
  89. ;===========================================================================;
  90.  
  91. GMS_Name:
  92.     dc.b    "games.library",0
  93.     even
  94. GMS_Base:
  95.     dc.l    0
  96.  
  97. AMT_PLANES =    5
  98.  
  99. ScreenStruct:
  100.     dc.l    "GSV1",0
  101.     dc.l    0,0,0                    ;Screen_Mem1/2/3
  102.     dc.l    0                        ;Screen link.
  103.     dc.l    Palette                  ;Address of palette.
  104.     dc.l    0                        ;Address of rasterlist.
  105.     dc.l    0                        ;Amt of colours in palette.
  106.     dc.w    320,256,320,256          ;Screen & Pic Height/Width.
  107.     dc.w    AMT_PLANES               ;Amt_Planes
  108.     dc.w    0,0                      ;X/Y screen offsets.
  109.     dc.w    0,0                      ;X/Y picture offsets.
  110.     dc.l    HSCROLL|VSCROLL|HBUFFER  ;Special attributes.
  111.     dc.w    LORES                    ;Screen mode.
  112.     dc.b    INTERLEAVED              ;Screen type
  113.     dc.b    0                        ;Reserved
  114.     even
  115.  
  116. Palette    dc.w    $0000,$0130,$0FCB,$0FA9,$0D88,$0965,$0644,$0211
  117.     dc.w    $0400,$0444,$0FF0,$0432,$0CC0,$0150,$0501,$0880
  118.     dc.w    $0261,$0271,$0382,$0492,$05A3,$05B4,$0677,$06C4
  119.     dc.w    $0788,$09AA,$0BCC,$0801,$0901,$0A02,$0701,$0601
  120.  
  121. Picture    dc.l    "PCV1",0           ;Version header.
  122.     dc.l    0                  ;Source data.
  123.     dc.w    320,256            ;Width, Height.
  124.     dc.w    AMT_PLANES         ;Amount of Planes.
  125.     dc.l    32                 ;Amount of colours.
  126.     dc.l    Palette            ;Source palette (remap).
  127.     dc.w    LORES              ;Screen mode.
  128.     dc.w    INTERLEAVED        ;Destination
  129.     dc.l    0                  ;Parameters.
  130.  
  131. PicFile    dc.b    "GAMESLIB:data/IFF.Pic320",0
  132.     even
  133.